package com.ds.robot.assistant.enums;


import lombok.Getter;

@Getter
public enum TimePoint {

    MORNING(1, "上午"),
    BEFORE_NOON(2, "中午前"),
    AFTERNOON(3, "下午"),
    BEFORE_CLOSE_OF_BUSINESS(4, "下班前");

    private final int value;
    private final String description;

    TimePoint(int value, String description) {
        this.value = value;
        this.description = description;
    }

    /**
     * 根据值查找描述
     *
     * @param value 枚举值
     * @return 描述字符串
     */
    public static String getDescriptionByValue(int value) {
        for (TimePoint timePoint : values()) {
            if (timePoint.getValue() == value) {
                return timePoint.getDescription();
            }
        }
        throw new IllegalArgumentException("No matching TimePoint for value: " + value);
    }


    public static TimePoint fromValue(int value) {
        for (TimePoint timePoint : values()) {
            if (timePoint.getValue() == value) {
                return timePoint;
            }
        }
        throw new IllegalArgumentException("Invalid value: " + value);
    }

    public static Integer getValueByDescription(String timePoint) {
        for (TimePoint tp : values()) {
            if (tp.getDescription().equals(timePoint)) {
                return tp.getValue();
            }
        }
        throw new IllegalArgumentException("No matching TimePoint for value: " + timePoint);
    }

}
